<template>
	<view class="box">
		<view class="head">
			<view class="head_left" @click="fanhui">
				<image src="http://oos-cn.ctyunapi.cn/hfclass/fanhui.png?Signature=UxKzt/fO7QiCKXVEBjkGnSGdoIw%3D&AWSAccessKeyId=65b300139cc5a0aa9572&Expires=865585101242"
				 style="width: 16rpx;height: 30rpx;margin-right: 20rpx;"></image>
				<text>返回</text>
			</view>
			<view style="position: relative;left: -16rpx;">14天上报记录</view>
			<view class="head_right">
				<!-- <image src="http://111.62.51.251:8081/hfclass/设置30X30.png"  style="width: 36rpx;height: 36rpx;" ></image> -->
				<!-- <view class="windows" v-if="IsSet">
					<view class="windows_box">
						<view @click="message">数据上报</view>
					</view>
				</view> -->
			</view>
		</view>

		<view class="dian"></view>
		<view class="conent">
			<!-- <view class="nav">今日数据</view>
			<view class="number" v-for="(item,index) in list" :key='index' @click="info(item.userHeath.id)">
				<view class="number_left">
					<view>{{item.userHeath.reportTime[0]}}</view>
					<view>{{item.userProfile.name}}</view>
				</view>
				<view class="number_right">
					<text>{{item.userHeath.temperature}}</text>
					<image src="http://oos-cn.ctyunapi.cn/hfclass/%E9%80%89%E6%8B%A9%E7%AE%AD%E5%A4%B415X22.png?Signature=8Ry%2BydghTC67iii673JW%2BmJlX5s%3D&AWSAccessKeyId=65b300139cc5a0aa9572&Expires=865585102035"></image>
				</view>
			</view> -->
			<view class="nav">14天历史数据</view>
			<view class="number" v-for="(item,index) in arr" :key='index' @click="info(item.userHeath.id,item.userHeath.userId,item.userHeath.reportTime[0])">
				<view class="number_left">
					<view>{{item.userHeath.reportTime[0]}}</view>
					<view>{{item.userProfile.name}}</view>
				</view>
				<view class="number_right">
					<text>{{item.userHeath.temperature}}</text>
					<image src="http://oos-cn.ctyunapi.cn/hfclass/%E9%80%89%E6%8B%A9%E7%AE%AD%E5%A4%B415X22.png?Signature=8Ry%2BydghTC67iii673JW%2BmJlX5s%3D&AWSAccessKeyId=65b300139cc5a0aa9572&Expires=865585102035"></image>
				</view>
			</view>
		</view>


	<!-- 	<view class="loading-text">
			{{contentText}}
		</view>
 -->
		<view v-if="loadModal" class="MaskLayer"></view>
		<view class="gif" v-if="loadModal">
			<view>
				<image src="http://oos-cn.ctyunapi.cn/hfclass/jiazai.gif?Signature=OgNX%2BUIeALb4HM35vCGC1jX%2BZEw%3D&AWSAccessKeyId=65b300139cc5a0aa9572&Expires=865585100785"></image>
				<view>请耐心等待！</view>
			</view>
		</view>
	</view>
</template>

<script>
	import App from '../../App.vue'
	export default {
		data() {
			return {
				arr: [],
				list: [],
				userId: '',
				loadingType: 1,
				contentText: "上划加载显示更多",
				loadModal: false
			}
		},
		created() {
			// this.getList()
		},
		onReachBottom() {
			//this.getNewsList(); //下拉
		},
		
		onLoad(op){
			
			var that=this
					
			if(op.id){
				that.userId=op.id
				that.getList()
				}
			// }else{
			// 	// if(this.userId==0||this.userId==null||this.userId==''||this.userId==undefined){
			// 	// 	this.gitObj()
			// 	// }
			// }
		},
		methods: {
			getList() {
				var that = this
				that.loadModal = true
				// uni.request({
				// 	method: 'POST',
				// 	url: App.globalData.baseUrl + '/api/services/app/session/GetCurrentLoginInformations',
				// 	success(res) {
				// 		if (res.data.result.user == undefined || res.data.result.user == null || res.statusCode == 500) {
				// 			that.loadModal = false
				// 			uni.showToast({
				// 				icon: 'none',
				// 				duration: 2000,
				// 				title: '未登录'
				// 			})
				// 			let cl = setTimeout(() => {
				// 				window.location.href = '/wx/GetCode'
				// 				clearTimeout(cl)
				// 			}, 2000)
						//} else {
							
							//that.userId = res.data.result.user.id
							// uni.request({
							// 	method: 'POST',
							// 	url: App.globalData.baseUrl + '/api/services/app/organUser/GetUserHealthHistoryList',
							// 	data: {
							// 		"userId": 0,
							// 		"sorting": "",
							// 		"skipCount": 0,
							// 		"maxResultCount": 20
							// 	},
							// 	success(res) {
							// 		if (res.data.result.items == [] || res.data.result.items == null) {
							// 			that.loadModal = false
							// 			uni.showToast({
							// 				title: '目前还没有提交记录哦！',
							// 				duration: 2000,
							// 				icon: 'none'
							// 			})
							// 		} else {
							// 			that.loadModal = false
							// 			that.list = res.data.result.items
							// 			that.list.forEach((item, index) => {
							// 				item.userHeath.reportTime = String(item.userHeath.reportTime).split('T')
							// 			})
							// 		}
							// 	},
							// 	fail(res) {
							// 		that.loadModal = false
							// 		uni.showToast({
							// 			icon: 'none',
							// 			duration: 2000,
							// 			title: '未登录'
							// 		})
							// 		let cl = setTimeout(() => {
							// 			window.location.href = '/wx/GetCode'
							// 			clearTimeout(cl)
							// 		}, 2000)
							// 	}
							// })

							uni.request({
								method:'POST',
								url:App.globalData.baseUrl + '/api/services/app/organUser/GetUserHealthBackHistoryListByUserId',
								data:{
									 "userId":that.userId,
									 "sorting": "",
									 "skipCount": 0,
									 "maxResultCount": 10
								},
								success(res) {
									
									if (res.data.success == true) {
									if(res.data.result.items==[]||res.data.result.items==null){
										that.loadModal=false
										uni.showToast({
											title:'目前还没有提交记录哦！',
											duration:2000,
											icon:'none'
										})
									}else{
										
										that.arr=res.data.result.items
										that.arr.forEach((item,index)=>{
											item.userHeath.reportTime=String(item.userHeath.reportTime).split('T')
										})
										that.loadModal=false
									}
									}else{
										
										that.loadModal=false
										uni.showToast({
											icon: 'none',
											title: res.data.error.message,
											duration: 4000
										})
										
										if (res.data.error.code == 401) {
										
										uni.showToast({
											icon: 'none',
											duration: 2000,
											title: '马上开始重新登录'
										})
										
											let cl = setTimeout(() => {
												window.location.href = '/wx/GetCode'
												clearTimeout(cl)
											}, 2000)
										
										
										}
										
									}
								},fail(res) {
									that.loadModal=false
									uni.showToast({
										icon: 'none',
										duration: 2000,
										title: '未登录'
									})
									let cl = setTimeout(() => {
										window.location.href = '/wx/GetCode'
										clearTimeout(cl)
									}, 2000)
								}
							})
						//}
					//},
				// 	fail(res) {
				// 		that.loadModal = false
				// 		uni.showToast({
				// 			title: res.data.error.message,
				// 			duration: 1000,
				// 			icon: 'none',
				// 		})
				// 	}
				// })
			},

			info(id,userId,date) {
				uni.navigateTo({
					url: '/pages/submit/information?id=' + id+'&userId='+userId+'&date='+date
				})
			},
			fanhui() {
				uni.redirectTo({
					url: '/pages/submit/informer'
				})
			},
			// getNewsList: function() { //第一次回去数据
			// 	var _self = this;
			// 	_self.loadingType++
			// 	uni.showNavigationBarLoading();
			// 	uni.request({
			// 		url: App.globalData.baseUrl + '/api/services/app/organUser/getUserHealthBackHistoryList',
			// 		method: 'POST',
			// 		data: {
			// 			"userId": _self.userId,
			// 			"sorting": "",
			// 			"skipCount": (_self.loadingType - 1) * 10,
			// 			"maxResultCount": 10
			// 		},
			// 		success: function(res) {
			// 			if (_self.arr.length == res.data.result.totalCount & res.data.success == true) {
			// 				_self.contentText = '没有更多的数据了'
			// 				uni.showToast({
			// 					title: '已是最新',
			// 					duration: 2000
			// 				});
			// 			} else if (res.data.success == true) {
			// 				var arrs = []
			// 				arrs = res.data.result.items
			// 				arrs.forEach((item, index) => {
			// 					item.userHeath.reportTime = String(item.userHeath.reportTime).split('T')
			// 				})
			// 				_self.arr = _self.arr.concat(arrs)
			// 			} else {
			// 				uni.showToast({
			// 					title: res.data.error.message,
			// 					icon: 'none',
			// 					duration: 1000
			// 				})
			// 			}
			// 			uni.hideNavigationBarLoading(); //关闭加载动画
			// 			uni.stopPullDownRefresh(); //得到数据后停止下拉刷新
			// 		},
			// 		fail(res) {
			// 			uni.hideNavigationBarLoading(); //关闭加载动画
			// 			uni.stopPullDownRefresh(); //得到数据后停止下拉刷新
			// 		}
			// 	});

			// }
		}
	}
</script>

<style scoped>
	.loading-text {
		text-align: center;
		height: 100rpx;
	}

	.box {
		width: 100%;
		height: 100%;
	}

	.head {
		height: 120rpx;
		width: 100%;
		background-color: #FFFFFF;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 30rpx;
		position: fixed;
		top: 0rpx;
		left: 0rpx;
		z-index: 100;
	}

	.head_left {
		display: flex;
		align-items: center;
	}

	.head_right {
		position: relative;
	}

	.windows {
		position: absolute;
		top: 60rpx;
		right: 10rpx;
	}

	.windows_box {
		width: 260rpx;
		background: #FFFFFF;
		padding: 0 30rpx;
		box-sizing: border-box;
		box-shadow: 0rpx 0rpx 6rpx #000;
		border-radius: 10rpx;
	}

	.windows_box>view {
		width: 100%;
		height: 90rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		text-align: center;
		line-height: 90rpx;
	}

	/* .windows_box>view:nth-child(1){
		border-bottom: 1rpx solid #888888;
	} */

	.dian {
		width: 100%;
		height: 120rpx;
	}

	.conent {
		width: 100%;
	}

	.nav {
		height: 90rpx;
		line-height: 90rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		;
	}

	.number {
		height: 100rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		background: #FFFFFF;
		margin-bottom: 30rpx;
	}

	.number_left {
		display: flex;
		align-items: center;
	}

	.number_left>view:nth-child(1) {
		margin-right: 20rpx;
	}

	.number_right,
	.number_left {
		display: flex;
		align-items: center;
	}

	.number_right>image {
		width: 16rpx;
		height: 30rpx;
		margin-left: 20rpx;
	}

	.number_right>text {
		color: #21D2A1;
	}

	/* 弹窗 */
	.MaskLayer {
		width: 100%;
		height: 100%;
		position: fixed;
		top: 0rpx;
		left: 0rpx;
		/* z-index: 101; */
		background: #000000;
		opacity: 0.6;
	}

	.gif>view>image {
		width: 160rpx;
		height: 160rpx;
	}

	.gif>view>view {
		color: #FFFFFF;
		text-align: center;
		margin-top: 10rpx;
		font-size: 28rpx;
	}

	.gif {
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		position: fixed;
		top: 0;
		left: 0;
		/* z-index: 101; */
	}
</style>
